package cn.laixueit.mapper;

import cn.laixueit.pojo.item.Brand;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface BrandMapper extends BaseMapper<Brand> {

    @Insert("INSERT INTO tb_category_brand(category_id, brand_id) VALUES (#{categoryId},#{brandId}) ")
    void saveBrandAndCategoryId(@Param("brandId")Long brandId,@Param("categoryId")Long categoryId);

    @Select("select * from tb_brand where id in (select brand_id from tb_category_brand where category_id =  #{cid})")
    List<Brand> findBrandListByCategoryId(Long cid);
}
